package mypackage;

import java.util.Arrays;
import java.util.Random;

public class testclass7 {
    public static void main(String[] args) {
        int[] arr=new int[]{10,88,588,3888,68888};
        choujiang(arr);
        choujiang2(arr);
    }
    public static void choujiang(int[] arr){
        Random r=new Random();
        for (int i = 0; i < arr.length; i++) {
            int temp=arr[i];
            int index=r.nextInt(arr.length);
            arr[i]=arr[index];
            arr[index]=temp;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
        System.out.println();
    }
    public static boolean check(int[] arr,int flag){
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]==flag){
                return true;
            }
        }
        return false;
    }
    public static void choujiang2(int[] arr){
        Random r=new Random();
        int[] newarr=new int[arr.length];
        for(int i=0;i<newarr.length;){
            int num=r.nextInt(arr.length);
            boolean flag=check(newarr,arr[num]);
            if(!flag){
                newarr[i]=arr[num];
                ++i;
            }
        }
        for (int i = 0; i < newarr.length; i++) {
            System.out.print(newarr[i]+" ");
        }
        System.out.println();
    }
}
